/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Trabalho3.RegrasPasswordChecker01;

import Trabalho3.RuleFactory;

/**
 *
 * @author geraldo
 */
public class RegraSimbolos implements RuleFactory{
    final int BONUS_SIMBOLOS_UNICO = 5;
    final int BONUS_SIMBOLOS_ACIMA_DE_UM = 10;
    final String SIMBOLOS = "!@#$%^&*?_~";
    String password;

    public RegraSimbolos(String password) {
        this.password = password;
    }
    
    @Override
    public int calcularRegra() {
        int counter = 0;
        char[] arraySenha = password.toCharArray();
        for (char c : arraySenha) {
            if (this.isSimbol(c)) {
                counter++;
            }
        }
        if (counter <= 0) {
            return 0;
        }
        return (counter > 1) ? BONUS_SIMBOLOS_ACIMA_DE_UM : BONUS_SIMBOLOS_UNICO;
    }
    
    public boolean isSimbol(char ch) {
        String Simbolos = SIMBOLOS;
        for (char c : Simbolos.toCharArray()) {
            if (ch == c) {
                return true;
            }
        }
        return false;
    }

    
    
    
}
